//2009/08/17 21:40:47
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class Party
{
public:
    double averageNames(int n, vector <int> personA, vector <int> personB)
    {
        bool know [101][101] = {false};
        for (int i=0; i < n; ++i)
            know[i][i] = true; // everyone knows their own name
        for (int i=0; i < personA.size(); ++i)
            for (int j=0; j < n; ++j)
                if (know[personA[i]][j] || know[personB[i]][j])
                    know[personA[i]][j] = know[personB[i]][j] = true;
        double total = 0;
        for (int i=0; i < n; ++i)
            for (int j=0; j < n; ++j)
                if (i != j && know[i][j])
                    total += 1;
        return total / n;

    }
};
